package org.pork.service;

import java.util.List;

import javax.inject.Inject;

import org.apache.log4j.Logger;
import org.pork.criteria.W_Criteria;
import org.pork.domain.WorkReportVO;
import org.pork.mapper.WorkReportMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
public class WorkReportService{

	@Inject
	WorkReportMapper mapper;
	
	private Logger logger = Logger.getLogger(WorkReportService.class);
	
	public void regist(WorkReportVO vo) throws Exception{
		
		logger.info("-----WorkReportService regist--------------------");
		logger.info(vo);
		
		mapper.create(vo);
		
	}
	
	@Transactional
	public WorkReportVO view(Integer seqno) throws Exception{
		
		logger.info("-----WorkReportService view--------------------");
		logger.info(seqno);
		
		mapper.updateReplyCnt(seqno);
		WorkReportVO vo = mapper.read(seqno);
		
		logger.info(vo);
		
		return vo;
	}
	
	public void modify(WorkReportVO vo) throws Exception{
		
		logger.info("-----WorkReportService modify--------------------");
		logger.info(vo);
		
		mapper.update(vo);
	}

	public void modifySubmit(Integer seqno) throws Exception{
		
		logger.info("-----WorkReportService modifySubmit--------------------");
		logger.info(seqno);
		
		mapper.updateSubmit(seqno);
	}
	
	public void remove(Integer seqno) throws Exception{
		
		logger.info("-----WorkReportService remove--------------------");
		logger.info(seqno);
		
		mapper.delete(seqno);
	}
	
	public List<WorkReportVO> list(W_Criteria cri) throws Exception{
		
		logger.info("-----WorkReportService list--------------------");
		logger.info(cri);
		
		List<WorkReportVO> list = mapper.list(cri);
		
		logger.info(list);
		
		return list;
	}
}
